// import svgIcon from '@/pages/components/svgIcon/index.vue'
const files = import.meta.globEager('@/components/*/*.vue')

export default {
  install (app) {
    // 批量导入全局模块
    for (const key in files) {
      // if (Object.prototype.hasOwnProperty.call(files, key)) {
      if (Reflect.has(files, key)) {
        /* const pathArr = key.match(/[a-z]+/gi)
        const name = pathArr[pathArr.length - 2]
          .replace(/([A-Z])/g, '-$1')
          .toLowerCase() */
        const name = key
          .substring(key.lastIndexOf('/') + 1, key.lastIndexOf('.vue'))
          .replace(/([A-Z])/g, '-$1')
          .toLowerCase()
        app.component(name, files[key].default)
      }
    }
  }
}
